package day14.KeJian;

public class Demo06 {
    public static void main(String[] args) {
        Object obj1 = new Object();
        Object obj2 = new Object();
        new Thread(()->{
            while (true){
                synchronized (obj1){
                    synchronized (obj2){
                        System.out.println("小黄同学正在喝饮料");
                    }
                }
            }
        }).start();
        new Thread(()->{
            while (true){
                synchronized (obj2){
                    synchronized (obj1) {
                        System.out.println("小黑同学正在吃冰淇淋");
                    }
                }
            }
        }).start();
    }
}
